package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.system.domain.SysFile;
import com.ruoyi.system.mapper.SysFileMapper;
import com.ruoyi.system.service.SysFileService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author wjb
* @description 针对表【sys_file(用户信息表)】的数据库操作Service实现
* @createDate 2024-06-19 11:27:37
*/
@Service
public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile>
    implements SysFileService{

	public SysFile insert(String username, String filePath, String fileName, String originalFileName) {
		// 封装对象
		SysFile sysFile = new SysFile();
		sysFile.setCreateBy(username);
		sysFile.setCreateTime(new Date());
		sysFile.setFilePath(filePath);
		sysFile.setFileName(fileName);
		sysFile.setOriginalFileName(originalFileName);
		sysFile.setFileSuffix(FileUtils.getSuffix(fileName));

		save(sysFile);

		return sysFile;
	}
}




